from PyQt5 import QtWidgets,QtGui
from PyQt5.QtWidgets import QMainWindow
from Source.beta.gui.MdGUI import Ui_MainWindow
import sys
from Source.beta.core import down
import threading

class mdlwindows(QMainWindow,Ui_MainWindow):
    # downloadButton = pyqtSignal()
    def __init__(self):
        super(mdlwindows, self).__init__()

        self.setupUi(self)
        self.downloadButton.clicked.connect(self.download)

    def download(self):
        path = self.path.text()
        name = self.name.text()
        url = self.m3u8url.text()
        if path!="" :
            if name!="" :
                if url!="":
                    self.infomation.setText("开始下载")
                    tt = threading.Thread(target=self.work,name="th",args=(url,path,name))
                    tt.start()
                else:
                    print("输入url")
            else:
                print("输入name")
        else:
            print("输入path")


    def work(self,url,path,name):
        w = down.down(url,path,name,10)
        w.download()




if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    mdl = mdlwindows()
    mdl.show()
    sys.exit(app.exec_())
